package cn.qdhlm.testrocketmq;

import cn.qdhlm.testrocketmq.rocketmqhelper.RocketMqConsumer;
import cn.qdhlm.testrocketmq.rocketmqhelper.RocketMqProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @Name:BootStrap
 * @description:
 * @author: xinY
 **/
@Component
public class BootStrap implements ApplicationRunner {
    @Autowired
    private RocketMqConsumer consumer;
    @Autowired
    private RocketMqProducer producer;
    @Override
    public void run(ApplicationArguments args) throws InterruptedException {
        System.out.println("applicationRunner start");
        System.out.println(producer.toString());

        for (int i = 0 ; i < 100 ; i ++){
            producer.send("server1","message from server1 : "+i);

            Thread.sleep(1000);
        }
        System.out.println(producer.toString());
    }
}
